package HomeWork3;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animaal [] animaal = new Animaal[4];
        animaal[0]=new Dog("小黑",3,"黑");
        animaal[1]=new Fish("小彩",1,"彩");
        animaal[2]=new Dog("小蓝",9,"蓝");
        animaal[3]=new Chick("小黄",4,"黄");
        for (int i = 0 ; i < animaal . length ; i++){
            System.out.println(animaal[i].name);
            animaal[i].drink();
            if (animaal[i] instanceof Dog){
               Dog dog=(Dog) animaal[i];
               dog.lookDoor();
            }
            if (animaal[i] instanceof Chick){
                Chick chick=(Chick) animaal[i];
                chick.layEggs();
            }
            if (animaal[i] instanceof Swim){
                Swim s=(Swim)animaal[i];
                s.swim();
                }
            }
        Master master=new Master();
        Dog dog = new Dog("小黑",3,"黑");
        Chick chick=new Chick("小黄",4,"黄");
        Fish fish=new Fish("小彩",1,"彩");
        master.feed(dog);
        master.feed(chick);
        master.feed(fish);
        }
    }

